<?php

declare(strict_types=1);
/*
 * This file is part of Leonsw.
 *
 * @link     https://leonsw.com
 * @document https://docs.leonsw.com
 * @contact  leonsw.com@gmail.com
 * @license  https://leonsw.com/LICENSE
 */
namespace App\Resource\Lottery3\User;


use Illuminate\Http\Resources\Json\JsonResource;

class Resource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'user_id' => $this->id,
            'nickname' => $this->nickname,
            'avatar' => $this->avatar,
            'score' => $this->score > $this->max_score ? $this->max_score : $this->score,
            'coin' => $this->info->money,
            'balance' => UserBalanceResource::collection($this->balance),
        ];
    }
}
